﻿@model TEWorkFlow.Domain.Archives.GoodsArchives
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>商品档案编辑</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="~/Styles/demo.css" />
    <script src="~/scripts/boot.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" method="post">
    <input name="Id" class="mini-hidden" value="@Model.Id" />
    <div style="padding-left: 11px; padding-bottom: 5px;">
        <table class="edittable" border="1" cellpadding="0" cellspacing="0">
    <tr>
        <td style="width: 80px;">
            店内码:
        </td>
        <td style="width: 120px;">
            <input name="GoodsCode" value="@Model.Id" class="mini-textbox" enabled="false" />
            <input name="PriceHistory" value="@Model.PriceHistory" class="mini-hidden" enabled="false" />
            <input name="ArticleNumber" value="@Model.ArticleNumber" class="mini-hidden" enabled="false" />
            <input name="PackUnitCode" value="@Model.PackUnitCode" class="mini-hidden" enabled="false" />
            <input name="OfferMode" value="@Model.OfferMode" class="mini-hidden" enabled="false" />
            <input name="PackCoef" value="@Model.PackCoef" class="mini-hidden" enabled="false" />
            <input name="OfferMin" value="@Model.OfferMin" class="mini-hidden" enabled="false" />
            <input name="InputTax" value="@Model.InputTax" class="mini-hidden" enabled="false" />
            <input name="OutputTax" value="@Model.OutputTax" class="mini-hidden" enabled="false" />
            <input name="StockUpperLimit" value="@Model.StockUpperLimit" class="mini-hidden" enabled="false" />
            <input name="StockLowerLimit" value="@Model.StockLowerLimit" class="mini-hidden" enabled="false" />
            <input name="UnderFloorCode" value="@Model.UnderFloorCode" class="mini-hidden" enabled="false" />
            <input name="UnderCounterCode" value="@Model.UnderCounterCode" class="mini-hidden" enabled="false" />
            <input name="AvgCost" value="@Model.AvgCost" class="mini-hidden" enabled="false" />
            <input name="NontaxAvgCost" value="@Model.NontaxAvgCost" class="mini-hidden" enabled="false" />
            <input name="GrossRate" value="@Model.GrossRate" class="mini-hidden" enabled="false" />
            <input name="SalePrice" value="@Model.SalePrice" class="mini-hidden" enabled="false" />
            <input name="VipPrice" value="@Model.VipPrice" class="mini-hidden" enabled="false" />
            <input name="TradePrice" value="@Model.TradePrice" class="mini-hidden" enabled="false" />
            <input name="PushRate" value="@Model.PushRate" class="mini-hidden" enabled="false" />
            <input name="CreateDate" value="@Model.CreateDate" class="mini-hidden" enabled="false" />
        </td>
        <td style="width: 80px;">
            条形码:
        </td>
        <td style="width: 120px;">
            <input name="GoodsBarCode" value="@Model.GoodsBarCode" class="mini-textbox" maxLength="20" required="false"/>
        </td>
        <td style="width: 80px;">
            商品简码:
        </td>
        <td style="width: 120px;">
            <input name="GoodsSubCode" value="@Model.GoodsSubCode" class="mini-textbox" maxLength="20" enabled="false"/>
        </td>
    </tr>
    <tr>
        <td>
            大类:
        </td>
        <td>
            <input name="GbCode" value="@Model.GbCode" id="GbCode" class="mini-combobox" textField="text" valueField="id" onvaluechanged="onGbCodeChanged" url="/category/GetFbPaGoodsGb/" showNullItem="true"  required="true"/>
        </td>
        <td>
            中类:
        </td>
        <td>
            <input name="GmCode" value="@Model.GmCode" id="GmCode" class="mini-combobox" textField="text" valueField="id" onvaluechanged="onGmCodeChanged" url="/Category/GetFbPaGoodsGm/" showNullItem="true"  required="true" />
        </td>
        <td>
            小类:
        </td>
        <td>
            <input name="GsCode" value="@Model.GsCode" id="GsCode" class="mini-combobox" textField="text" valueField="id" onvaluechanged="onGsCodeChanged" url="/Category/GetFbPaGoodsGs/" showNullItem="true"  required="true" />
        </td>
    </tr>
    <tr>
        <td>
            细类:
        </td>
        <td>
            <input name="GlCode" value="@Model.GlCode" id="GlCode" class="mini-combobox" textField="text" valueField="id" url="/Category/GetFbPaGoodsGl/" showNullItem="true"  required="true" />
        </td>
        <td>
            扣率:
        </td>
        <td>
            <input name="PoolRate" value="@Model.PoolRate" class="mini-spinner" decimalPlaces="2"/>
        </td>
        <td>
        </td>
        <td>
        </td>
    </tr>
    <tr>
        <td>
            供货商:
        </td>
        <td colspan="5">
            <input name="SupCode" class="mini-combobox"  textField="SupName" valueField="Id" multiSelect="true" allowInput="false" emptyText="请选择..." url="/Archives/GetAllSupplierArchive/?pageSize=999999" value="@Model.SupCode" valueFromSelect="true" required="true" style="width:100%" />
        </td>
    </tr>
    <tr>
        <td>
            商品名称:
        </td>
        <td>
            <input id="GoodsName" name="GoodsName" value="@Model.GoodsName" class="mini-textbox" maxLength="25" required="true"/>
        </td>
        <td>
            商品简称:
        </td>
        <td>
            <input id="GoodsSubName" onfocus="autoFillSubName()" name="GoodsSubName" value="@Model.GoodsSubName" class="mini-textbox" maxLength="10"/>
        </td>
        <td>
            拼音数字码:
        </td>
        <td>
            <input id="PyCode" name="PyCode" value="@Model.PyCode" class="mini-textbox"/>
        </td>
    </tr>
    @*    <tr>
        <td>
            商品状态:
        </td>
        <td>
            <input name="GoodsState" value="@Model.GoodsState" class="mini-textbox" />
        </td>
        <td>
            产地:
        </td>
        <td>
            <input name="ProducingArea" value="@Model.ProducingArea" class="mini-textbox"/>
        </td>
        <td>
            货号:
        </td>
        <td>
            <input name="ArticleNumber" value="@Model.ArticleNumber" class="mini-textbox"/>
        </td>
    </tr>
    <tr><td>
            产地:
        </td>
        <td>
            <input name="ProducingArea" value="@Model.ProducingArea" class="mini-textbox"/>
        </td>
        <td>
            规格:
        </td>
        <td>
            <input name="Specification" value="@Model.Specification" class="mini-textbox"/>
        </td>
        <td>
            保质期:
        </td>
        <td>
            <input name="ShelfLife" value="@Model.ShelfLife" class="mini-datepicker"/>
        </td>
        <td>
            包装单位:
        </td>
        <td>
            <input name="PackUnitCode" value="@Model.PackUnitCode" class="mini-textbox"/>
        </td>
    </tr>
    <tr>
        <td>
            供货方式:
        </td>
        <td>
            <input name="OfferMode" value="@Model.OfferMode" class="mini-textbox" />
        </td>
        <td>
            包装系数:
        </td>
        <td>
            <input name="PackCoef" value="@Model.PackCoef" class="mini-textbox"/>
        </td>
        <td>
            最小订量:
        </td>
        <td>
            <input name="OfferMin" value="@Model.OfferMin" class="mini-spinner" />
        </td>
    </tr>
    <tr>
        <td>
            进项税率:
        </td>
        <td>
            <input name="InputTax" value="@Model.InputTax" class="mini-spinner" />
        </td>
        <td>
            销项税率:
        </td>
        <td>
            <input name="OutputTax" value="@Model.OutputTax" class="mini-spinner"/>
        </td>
        <td>
            库存上限:
        </td>
        <td>
            <input name="StockUpperLimit" value="@Model.StockUpperLimit" class="mini-spinner" />
        </td>
    </tr>
    <tr>
        <td>
            库存下限:
        </td>
        <td>
            <input name="StockLowerLimit" value="@Model.StockLowerLimit" class="mini-spinner" />
        </td>
        <td>
            所属楼层:
        </td>
        <td>
            <input name="UnderFloorCode" value="@Model.UnderFloorCode" class="mini-textbox"/>
        </td>
        <td>
            所属柜台:
        </td>
        <td>
            <input name="UnderCounterCode" value="@Model.UnderCounterCode" class="mini-textbox"/>
        </td>
    </tr>*@
    <tr>
        @*        <td>
            核算单位:
        </td>
        <td>
            <input name="CheckUnitCode" value="@Model.CheckUnitCode" class="mini-textbox" />
        </td>*@
        <td>
            进价:
        </td>
        <td>
            <input id="PurchasePrice" name="PurchasePrice" value="@Model.PurchasePrice" class="mini-spinner" decimalPlaces="2" maxValue="99999" />
        </td>
        <td>
            建议零售价:
        </td>
        <td>
            <input id="ProposePrice" name="ProposePrice" value="@Model.ProposePrice" class="mini-spinner" decimalPlaces="2" maxValue="99999" />
        </td>
        @*   </tr>
    <tr>
        <td>
            不含税进价:
        </td>
        <td>
            <input name="NontaxPurchasePrice" value="@Model.NontaxPurchasePrice" class="mini-spinner" decimalPlaces="2" maxValue="99999"/>
        </td>
        <td>
            平均成本:
        </td>
        <td>
            <input name="AvgCost" value="@Model.AvgCost" class="mini-spinner" decimalPlaces="2" />
        </td>
        <td>
            含税平均成本:
        </td>
        <td>
            <input name="NontaxAvgCost" value="@Model.NontaxAvgCost" class="mini-spinner" decimalPlaces="2" />
        </td>
    </tr>
    <tr>
        <td>
            毛利率:
        </td>
        <td>
            <input name="GrossRate" value="@Model.GrossRate" class="mini-spinner" decimalPlaces="2" />
        </td>
        <td>
            销售价:
        </td>
        <td>
            <input name="SalePrice" value="@Model.SalePrice" class="mini-spinner" decimalPlaces="2" />
        </td>
        <td>
            会员价:
        </td>
        <td>
            <input name="VipPrice" value="@Model.VipPrice" class="mini-spinner" decimalPlaces="2" />
        </td>
    </tr>
    <tr>
        <td>
            批发价:
        </td>
        <td>
            <input name="TradePrice" value="@Model.TradePrice" class="mini-spinner" decimalPlaces="2" />
        </td>
        <td>
            营业员提成:
        </td>
        <td>
            <input name="PushRate" value="@Model.PushRate" class="mini-spinner" decimalPlaces="2" />
        </td>
        <td>
            创建时间:
        </td>
        <td>
            <input name="CreateDate" value="@Model.CreateDate" class="mini-datepicker" />
        </td>
    </tr>*@
        <td>
            操作员:
        </td>
        <td>
            <input name="Operator" class="mini-combobox"  textField="text" valueField="id" emptyText="请选择..." url="/Category/AllUsers" value="@Model.Operator"  allowInput="false" showNullItem="true" nullItemText="请选择..."/>
        </td>
    </tr>
    <tr>
        <td>
            审核人:
        </td>
        <td>
            <input name="Assessor" class="mini-combobox"  textField="text" valueField="id" emptyText="请选择..." url="/Category/AllUsers" value="@Model.Assessor"  allowInput="false" showNullItem="true" nullItemText="请选择..."/>
        </td>
        <td>
            是否审核:
        </td>
        <td align="left" style="text-align: left">
            <div name="IfExamine" class="mini-checkbox" value="@Model.IfExamine" readOnly="false" text="审核"  trueValue="1" falseValue="0">
            </div>
        </td>
        <td>
            审核时间:
        </td>
        <td>
            <input name="ExamineDate" value="@Model.ExamineDate" class="mini-datepicker"/>
        </td>
    </tr>
    <tr>
        <td>
            操作时间:
        </td>
        <td>
            <input name="OperatorDate" value="@Model.OperatorDate" class="mini-datepicker" />
        </td>
        <td>
            产地:
        </td>
        <td>
            <input name="ProducingArea" value="@Model.ProducingArea" class="mini-textbox" maxLength="10"/>
        </td>
        <td>
            规格:
        </td>
        <td>
            <input name="Specification" value="@Model.Specification" class="mini-textbox" maxLength="20"/>
        </td>
    </tr>
    <tr>
        <td>
            是否新品:
        </td>
        <td>
            <div name="IfNew" class="mini-checkbox" checked="@Model.IfNew" readOnly="false" text="新品">
            </div>
        </td>
        <td>
            备用码:
        </td>
        <td>
            <input name="BackupCode" value="@Model.BackupCode" class="mini-textbox" maxLength="20"/>
        </td>
        <td>
            数量类型
        </td>
        <td>
            <input name="QtyType" value="@Model.QtyType" class="mini-textbox" maxLength="1"/>
        </td>
    </tr>
    <tr>
        <td>
            备注:
        </td>
        <td colspan="5" style="width: 548px;">
            <input name="Remark" value="@Model.Remark" class="mini-textarea"  maxLength="250" style="width:548px;"/>
        </td>
    </tr>
    @*    <tr>
        <td>
            历史进价:
        </td>
        <td colspan="5">
            <input name="PriceHistory" value="@Model.PriceHistory" class="mini-textarea" width="100%" enabled="false"/>
        </td>
    </tr>*@
</table>
    </div>
    <div style="text-align: center; padding: 0 10px 10px 10px;">
        <a class="mini-button" onclick="onOkAndContinue" style="width: 100px; margin-right: 20px;">保存并继续添加</a>
        <a class="mini-button" onclick="onOk" style="width: 60px; margin-right: 20px;">确定</a>
        <a class="mini-button" onclick="onCancel" style="width: 60px;">取消</a>
    </div>
    </form>
    <script type="text/javascript">
        var entityId = "@Model.Id";
        mini.parse();

        var form = new mini.Form("form1");

        function GetData() {
            var o = form.getData();
            return o;
        }
        function CloseWindow(action) {
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function onOk(e) {
            SaveData();
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }

    </script>
    <script type="text/javascript">
        var clsGrade = @TEWorkFlow.Web.Client.Common.MyEnv.GetFbPaBaseSetService().Get().GoodsClassLevel;
        mini.parse();


        function onOkAndContinue(){
            var form = new mini.Form("form1");
            var o = form.getData(true);

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode([o]);

            $.ajax({
                type: "post",
                url: "/Archives/SaveGoodsArchive",
                data: o,
                cache: false,
                success: function (json) {
                    if(json.IsSuccess==true){
                        //CloseWindow("save");
                        mini.alert("点击确定继续添加新品", "保存成功", function(){
                            mini.get("#GoodsName").setValue("");
                            mini.get("#GoodsSubName").setValue("");
                            mini.get("#PyCode").setValue("");
                            mini.get("#PurchasePrice").setValue(0);
                            mini.get("#ProposePrice").setValue(0);
                            mini.get("#GoodsName").focus();
                        });
                        
                    }else{
                        alert(json.Message);
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }

        function SaveData() {
            var form = new mini.Form("form1");
            var o = form.getData(true);

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode([o]);

            $.ajax({
                type: "post",
                url: "/Archives/SaveGoodsArchive",
                data: o,
                cache: false,
                success: function (json) {
                    if(json.IsSuccess==true){
                        CloseWindow("save");
                    }else{
                        alert(json.Message);
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
        }
        var GbCode = mini.get("GbCode");
        var GmCode = mini.get("GmCode");
        var GsCode = mini.get("GsCode");
        var GlCode = mini.get("GlCode");
        if (clsGrade < 4) {
            GlCode.disable();
            GlCode.required = false;
        }
        if (clsGrade < 3) {
            GsCode.disable();
            GsCode.required = false;
        }
        if (clsGrade < 2) {
            GmCode.disable();
            GmCode.required = false;
        }
        if (clsGrade < 1) {
            GbCode.disable();
            GbCode.required = false;
        }
        function onGbCodeChanged() {
            var id = GbCode.getValue();
            var url = "/Category/GetFbPaGoodsGm/" + id
            GmCode.setUrl(url);
        }
        function onGmCodeChanged() {
            var id = GmCode.getValue();
            var url = "/Category/GetFbPaGoodsGs/" + id
            GsCode.setUrl(url);
        }
        function onGsCodeChanged() {
            var id = GsCode.getValue();
            var url = "/Category/GetFbPaGoodsGl/" + id
            GlCode.setUrl(url);
        }
        function autoFillSubName(){
            //alert(mini.get("#GoodsName").getValue()!="" && mini.get("#GoodsSubName").getValue()=="")
            if(mini.get("#GoodsName").getValue()!="" && mini.get("#GoodsSubName").getValue()=="")
                {
                    mini.get("#GoodsSubName").setValue(mini.get("#GoodsName").getValue());
                    mini.get("#PyCode").focus();
                }
        }
    </script>
</body>
</html>



